﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
///CommonInfo 的摘要说明
/// </summary>
public class CommonInfo
{
	public CommonInfo()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
	}

    public static System.Collections.Hashtable GetMyContractCenterList(string companyId)
    {
        System.Collections.Hashtable list = null;
        switch (companyId)
        {
            case "80985015-8f8a-4da4-a660-f89176da2fe5"://上海
                list = AddShangHaiContractCenter();
                break;
            case "ca2a06be-4731-4117-80b4-6ed488ce7f34"://苏州
                list = AddSuzhouContractCenter();
                break;
            default:
                list = null;
                break;
        }

        return list;
    }

    public static string GetMyContractCenterListJson(string companyId)
    {
        System.Collections.Hashtable list = null;
        switch (companyId)
        {
            case "80985015-8f8a-4da4-a660-f89176da2fe5"://上海
                list = AddShangHaiContractCenter();
                break;
            case "ca2a06be-4731-4117-80b4-6ed488ce7f34"://苏州
                list = AddSuzhouContractCenter();
                break;
            default:
                list = null;
                break;
        }

        if (list == null)
            return string.Empty;
        else
            return Convert2Json(list);
    }

    private static System.Collections.Hashtable AddSuzhouContractCenter()
    {
        System.Collections.Hashtable list = new System.Collections.Hashtable();
        list.Add("00000000-0000-0000-0000-000000000001", "苏州签约中心");

        return list;
    }

    private static System.Collections.Hashtable AddShangHaiContractCenter()
    {
        System.Collections.Hashtable list = new System.Collections.Hashtable();
        list.Add("00000000-0000-0000-0000-000000000000","文武大楼签约中心");
        list.Add("11111111-1111-1111-1111-111111111111", "创展大厦签约中心");
        list.Add("22222222-2222-2222-2222-222222222222","浦东签约中心");
        list.Add("33333333-3333-3333-3333-333333333333", "报春路签约中心");
        list.Add("44444444-4444-4444-4444-444444444444", "富贵东道签约中心");
        
        return list;
    }

    private static string Convert2Json(System.Collections.Hashtable list)
    {
        if (list == null) return "[]";
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        sb.Append("([");
        bool bAdd = false;
        foreach (string strKey in list.Keys)
        {
            if (bAdd)
                sb.AppendFormat(",{{txt:\"{0}\",val:\"{1}\"}}", list[strKey].ToString(), strKey);
            else
                sb.AppendFormat("{{txt:\"{0}\",val:\"{1}\"}}", list[strKey].ToString(), strKey);

            bAdd = true;
        }
        sb.Append("])");

        return sb.ToString();
    }
}
